﻿using SYJ.Common.Filters;
using SYJ.Filter;
using SYJ.Logic;
using SYJ.Model.Entities;
using System.Web;
using System.Web.Mvc;

namespace SYJ
{
    public class FilterConfig
    {
        public static void RegisterGlobalFilters(GlobalFilterCollection filters)
        {
            bool user = false;
            if (AppContext.Current!=null) {
                if (AppContext.Current.User != null) {
                    user = true;
                }
            }

            filters.Add(new LoginAttribute() { IsNotAuthorized = (filterContext) => { return user; } });
            filters.Add(new HandlerErrorAttribute());
            filters.Add(new HandleErrorAttribute());
        }
    }
}